/*
 * Copyright (c) 2019.  黄钰朝
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hyc.www.dao;

import com.hyc.www.dao.annotation.Query;
import com.hyc.www.dao.annotation.Result;
import com.hyc.www.dao.annotation.ResultType;
import com.hyc.www.dao.core.BaseDao;
import com.hyc.www.model.po.Order;
import com.hyc.www.model.po.Ticket;
import com.hyc.www.model.po.User;

import java.math.BigInteger;
import java.util.List;

/**
 * @author <a href="mailto:kobe524348@gmail.com">黄钰朝</a>
 * @program www
 * @description 负责User类CRUD
 * @date 2019-05-01 23:39
 */
public interface OrderDao extends BaseDao {
    String TABLE = "ticket_order";
    String ALL_FIELD = "user_id,ticket_id,number," + BASE_FIELD;


    /**
     * 查询车票订单
     *
     * @param userId      where中的限制条件
     * @name listTicketByUid
     * @author <a href="mailto:kobe524348@gmail.com">黄钰朝</a>
     * @date 2019/7/17
     */
    @Result(entity = Order.class, returns = ResultType.LIST)
    @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where user_id = ?")
    List listOrderByUid(Object userId);

    /**
     * 通过id查询车票订单
     *
     * @param id
     * @notice none
     * @author <a href="mailto:kobe524348@gmail.com">黄钰朝</a>
     * @date 2019/7/18
     */
    @Result(entity = Order.class, returns = ResultType.OBJECT)
    @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where id = ? ")
    Order getOrderById(BigInteger id);

}
